<template>
  <div>
    <div class="progress-main">
      <template v-for="(item, index) in data" :key="index">
        <div
          class="progress-item"
          :class="index < number ? 'active' : ''"
          :style="[`width:${width}`]"
        >
          <div
            class="icon"
            :class="item.icon == '' ? 'icon-home' : item.icon"
          ></div>
          <div>
            {{ item.title }}
          </div>
          <div class="text-grey fz12">
            {{ item.time }}
          </div>
        </div>
      </template>
    </div>
  </div>
</template>

<script lang="ts">
export default {
  name: "ui-progress",
};
</script>
<script setup lang="ts">
import {
  ref,
  computed,
  watch,
  getCurrentInstance,
  onMounted,
  nextTick,
} from "vue";

const props = withDefaults(
  defineProps<{
    width?: string;
    data?: Array<{
      icon: string;
      title: string;
      time: string;
    }>;
    number?: number;
  }>(),
  {
    width: "50%",
    data: () => {
      return [];
    },
    number: 0,
  }
);
</script>

<style scoped>
.progress-main {
  line-height: 26px;
  width: calc(100% - 20px);
  display: flex;
  justify-content: center;
  background: #f0f0f0f0;
  border-radius:5px;
  padding: 20px 10px;
}
.progress-item {
  text-align: center;
  position: relative;
  color: var(--base-grey);
}
.progress-item::after {
  position: absolute;
  content: "";
  height: 2px;
  width: 30%;
  left: 0;
  top: 26px;
  background: var(--base-grey);
}
.progress-item:first-child::after {
  display: none;
}
.progress-item::before {
  position: absolute;
  content: "";
  height: 2px;
  width: 30%;
  right: 0;
  top: 26px;
  background: var(--base-grey);
}
.progress-item:last-child::before {
  display: none;
}
.progress-item.active {
  color: var(--base-default);
}
.progress-item.active::before,
.progress-item.active::after {
  background: var(--base-default);
}
</style>